//
//  FeedContainerViewController.swift
//  DouyinDemo
//
//  Created by MAC on 2022/3/7.
//

import UIKit
import SnapKit//做自动布局的库

class FeedContainerViewController: UIViewController,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{
    
    private var collectionView:UICollectionView!
    private var collectionViewLayout:UICollectionViewFlowLayout!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        //collection view layout
        collectionViewLayout = UICollectionViewFlowLayout()
        collectionViewLayout.scrollDirection = .horizontal//滚动方向，水平
        collectionViewLayout.minimumLineSpacing = 0
        
        //collection view
        collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
        collectionView.dataSource = self
        collectionView.delegate = self
        collectionView.register(FeedContainerViewController.self, forCellWithReuseIdentifier: FeedContainerCollectionViewCell.reuseIdentifierString)
        
        view.addSubview(collectionView)
        
        collectionView.snp.makeConstraints{make in
            make.edges.equalTo(0)
        }
        
    }
    
    //MARK:UICollectionViewDelegateFlowLayout
    
    
    
    //MARK:UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return 2
    }

  
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FeedContainerCollectionViewCell.reuseIdentifierString, for: indexPath)as!FeedContainerCollectionViewCell
        
        return cell
    }
    
    
    
    
}
